//
//  RealHouseSearchViewController.m
//  Utils
//
//  Created by enghou on 2018/4/28.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "RealHouseSearchViewController.h"
#import "NSMutableDictionary+SetContent.h"
@interface RealHouseSearchViewController ()

@end

@implementation RealHouseSearchViewController

-(NSDictionary *)param{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setObject:self.addressField.text forKey:@"searchVo.address"];
    [param setObject:self.manipulatorNameField.text forKey:@"searchVo.name"];
    [param setObject:self.nowLocateAddress.text forKey:@"searchVo.nowLiveAddress"];
    [param setContent:self.usageModel.ids forKey:@"searchVo.houseUses.id" conentNeeded:NO];
    if (self.yesBtn.selected) {
        [param setContent:@"true" forKey:@"searchVo.isRentalHouse" conentNeeded:NO];
    }else{
        [param setContent:@"false" forKey:@"searchVo.isRentalHouse" conentNeeded:NO];
    }
    [param setContent:self.lowerField.text forKey:@"searchVo.houseAreaStart" conentNeeded:NO];
    [param setContent:self.heigherField.text forKey:@"searchVo.houseAreaEnd" conentNeeded:NO];
    return param;
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

-(void)selectUsage{
    if (!self.usages) {
        [self commonAlertWithContent:@"房屋用途" choosenBlock:^(PropertyDictItemModel *model) {
            self.usageModel = model;
            self.usageField.text = self.usageModel.displayName;
        } getList:^(NSArray *array) {
            self.usages = array;
        }];
    }else{
        [self alertWithArray:self.usages choosenBock:^(PropertyDictItemModel *model) {
            self.usageModel = model;
            self.usageField.text = self.usageModel.displayName;
        }];
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 3) {
        [self selectUsage];
    }
}

- (IBAction)yesAction:(id)sender {
    self.yesBtn.selected = YES;
    self.notBtn.selected = NO;
}

- (IBAction)noAction:(id)sender {
    self.yesBtn.selected = NO;
    self.notBtn.selected = YES;
}
@end
